var pRate = function(box,callBack){
	 this.Index = null;
	 var B = $("#"+box),
	  rate = B.children("i"),
	  w = rate.width(),
	  n = rate.length,
	  me = this;
	 for(var i=0;i<n;i++){
	  rate.eq(i).css({
	   'width':w*(i+1),
	   'z-index':n-i
	  });
	 } 
	 rate.hover(function(){
	  var S = B.children("i.select");
	  $(this).addClass("hover").siblings().removeClass("hover");
	  if($(this).index()>S.index()){
	   S.addClass("hover");
	  }
	 },function(){
	  rate.removeClass("hover");
	 })
	 rate.click(function(){
	  rate.removeClass("select hover");
	  $(this).addClass("select");
	  me.Index = $(this).index() + 1;
	  if(callBack){callBack();}
	 })
}


var Rate1 = new pRate("p_rate1",function(){
	$('#stars1_tips').text(Rate1.Index+'分');
	$('#stars1_input').attr('value',Rate1.Index);
});
var Rate2 = new pRate("p_rate2",function(){
	$('#stars2_tips').text(Rate2.Index+'分');
	$('#stars2_input').attr('value',Rate2.Index);
});
var Rate3 = new pRate("p_rate3",function(){
	$('#stars3_tips').text(Rate3.Index+'分');
	$('#stars3_input').attr('value',Rate3.Index);
});

